// pages/Reward/Reward.js
const app = getApp();
const db = wx.cloud.database();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    CustomBar: app.globalData.CustomBar,
    img:'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3573548092,3287681940&fm=26&gp=0.jpg',
    myRewards:[
      
    ]
  },
  tochoose(){
    wx.navigateTo({
      url: 'RewardList/RewardList',
    })
  },
  onShow:function(){
    var that = this;
    //console.log(app.eduOS.xh);
    db.collection('rewardList').where({
      myxh: app.eduOS.xh
    }).get({
      success(res) {
        console.log(res)
        that.setData({
          myRewards: res.data
        })
      }
    })
  },
  onLoad: function (options) {
    
  },
  showModal(e) {
    this.setData({
      modalName: e.currentTarget.dataset.target
    })
  },
  hideModal(e) {
    this.setData({
      modalName: null
    })
  },
  onPullDownRefresh: function () {
    //刷新数据
    wx.showLoading({
      title: '刷新数据ing~',
    })
    var that = this;
    //console.log(app.eduOS.xh);
    db.collection('rewardList').where({
      myxh: app.eduOS.xh
    }).get({
      success(res) {
        wx.stopPullDownRefresh()
        wx.hideLoading()
        console.log(res)
        that.setData({
          myRewards: res.data
        })
      }
    })
  }
})